import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluwx/fluwx.dart' as fluwx;
import 'package:get/get.dart';
import 'package:sp_util/sp_util.dart';
import 'package:video_player/video_player.dart';
import 'package:yp/Xwidgets/cache_image.dart';
import 'package:yp/Xwidgets/line.dart';
import 'package:yp/config/config.dart';
import 'package:yp/config/style.dart';
import 'package:yp/services/api.dart';
import 'package:yp/utils/videoplayer/video_player_plus.dart';
import '../../helper.dart';
import '../../router.dart';
import 'logic.dart';
import 'state.dart';

class OrderCompletePage extends StatefulWidget {
  @override
  _OrderCompletePageState createState() => _OrderCompletePageState();
}

class _OrderCompletePageState extends State<OrderCompletePage> {
  final orderCompleteLogic logic = Get.put(orderCompleteLogic());

  final orderCompleteState state = Get.find<orderCompleteLogic>().state;
  Map root;
  getrecommendGoods() {
    var params = {
      "fission_condition_least_cost": SpUtil.getDouble('need_pay_amount'),
      'access_token': SpUtil.getString('token'),
      'tml_num_id': SpUtil.getString('tml_num_id'),
    };
    Api.fissionTrigger(params).listen((event) {
      if (event["code"] == 0) {
        root = event;
        if (event['event_num_id'] != null) {
          showModalBottomSheet<void>(
              context: context,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(20),
                  topRight: Radius.circular(20),
                ),
              ),
              builder: (BuildContext context) {
                return Container(
                  width: 750.w,
                  height: 500.w,
                  color: Colors.white,
                  child: Column(children: [
                    SizedBox(
                      height: 20.w,
                    ),
                    Text(
                      '本次下单奖励',
                      style: TextStyle(fontSize: 36.sp, color: Colors.brown),
                      textAlign: TextAlign.center,
                    ),
                    SizedBox(
                      height: 20.w,
                    ),
                    GestureDetector(
                        onTap: () {
                          print(root);
                          // var url = Config.WEB_URL +
                          //     'random_amount?activity_num_id=' +
                          //     root['bl_fission_hdr']['activity_num_id'] +
                          //     '&event_num_id=' +
                          //     root['event_num_id'].toString();
                          var url = Config.H5_URL +
                              '&isGoHongBao=true&event_num_id=' +
                              root['event_num_id'].toString() +
                              '&activityId=' +
                              root['bl_fission_hdr']['activity_num_id']
                                  .toString();
                          var model = fluwx.WeChatShareWebPageModel(
                            url,
                            description: root['bl_fission_hdr']
                                ['activity_share_content'],
                            title: root['bl_fission_hdr']
                                ['activity_share_title'],
                            thumbnail: fluwx.WeChatImage.network(
                                root['bl_fission_hdr']
                                    ['activity_share_banner_url']),
                            scene: fluwx.WeChatScene.SESSION,
                          );

                          print("url===$url");
                          fluwx.shareToWeChat(model);
                        },
                        child: Image.asset(
                          'assets/images/shouqi.jpg',
                          width: 700.w,
                          height: 150.w,
                          fit: BoxFit.cover,
                        ))
                  ]),
                );
              });
        }
      }
    });
  }

  @override
  void initState() {
    super.initState();
    var timer = Timer(const Duration(milliseconds: 0), () {
      try {
        getrecommendGoods();
      } catch (e) {}
    });
  }

  @override
  Widget build(BuildContext context) {
    Widget _guessLickTitle() {
      return Padding(
        padding: const EdgeInsets.symmetric(horizontal: 30),
        child: Row(
          children: [
            Expanded(child: YpLine()),
            Container(
              width: 5,
              height: 5,
              decoration: BoxDecoration(
                color: EsColors.BackGround,
                borderRadius: BorderRadius.circular(10),
              ),
            ),
            SizedBox(width: 10),
            Text('猜你喜欢',
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.LG,
                    fontWeight: EsFontWeights.Medium)),
            SizedBox(width: 10),
            Container(
              width: 5,
              height: 5,
              decoration: BoxDecoration(
                color: EsColors.BackGround,
                borderRadius: BorderRadius.circular(10),
              ),
            ),
            Expanded(child: YpLine()),
          ],
        ),
      );
    }

    /// 猜你喜欢
    Widget _guessLick() {
      return Padding(
        padding: EdgeInsets.only(
            left: 12,
            right: 12,
            top: 20,
            bottom: MediaQuery.of(context).padding.bottom + 10),
        child: Wrap(
          spacing: 10,
          runSpacing: 10,
          children: List.generate(
              state.TJlist.length,
              (index) => GestureDetector(
                    behavior: HitTestBehavior.opaque,
                    onTap: () {
                      print('点击猜你喜欢的商品详情');
                      if (state.TJlist[index]['style_store'] > 0) {
                        Get.toNamed(RouteConfig.goodsDetail, arguments: {
                          'itemNumId':
                              state.TJlist[index]['item_num_id'].toString(),
                          'styleNumId':
                              state.TJlist[index]['style_num_id'].toString(),
                          // 'shopId': SpUtil.getInt('storeShopNum').toString(),
                          'shopId':
                              SpUtil.getObject(Config.GET_SHOP_INFO)['shop_id']
                                  ?.toString(),
                          'ecStyleNumId':
                              state.TJlist[index]['ec_style_num_id'].toString(),
                          'typeIndex': state.TJlist[index]['is_pre_sale'] ?? 0,
                        });
                      }
                    },
                    child: Container(
                      decoration: EsDecoration.BoxShadowDefault,
                      width: MediaQuery.of(context).size.width / 2 - 18,
                      padding: const EdgeInsets.only(
                          left: 12, right: 12, bottom: 16),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Stack(
                            children: [
                              CachedImage(
                                path: state.TJlist[index]['image_default_id'],
                                width:
                                    MediaQuery.of(context).size.width / 2 - 24,
                                height:
                                    MediaQuery.of(context).size.width / 2 - 24,
                              ),
                              Positioned(
                                left: setWidth(97),
                                top: setWidth(106),
                                child: state.TJlist[index]['style_store'] <= 0
                                    ? Container(
                                        width: setWidth(120),
                                        height: setWidth(120),
                                        alignment: Alignment.center,
                                        decoration: BoxDecoration(
                                          color: Color(0xffbbbbbb)
                                              .withOpacity(0.7),
                                          borderRadius: BorderRadius.circular(
                                              setWidth(60)),
                                        ),
                                        child: Text(
                                          '售罄',
                                          style: TextStyle(
                                            color: Colors.white,
                                            fontSize: 15,
                                          ),
                                        ),
                                      )
                                    : SizedBox(),
                              ),
                            ],
                          ),
                          Text(state.TJlist[index]['title'],
                              maxLines: 1,
                              overflow: TextOverflow.ellipsis,
                              style: TextStyle(
                                  color: EsColors.TitleSecondary,
                                  fontSize: EsSizes.MD,
                                  fontWeight: EsFontWeights.Normal)),
                          SizedBox(height: 16),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              RichText(
                                maxLines: 1,
                                overflow: TextOverflow.ellipsis,
                                text: TextSpan(
                                    text:
                                        logic.getMoney(state.TJlist[index])[0],
                                    style: TextStyle(
                                        fontSize: EsSizes.LG,
                                        color: EsColors.Primary,
                                        fontWeight: EsFontWeights.Medium),
                                    children: <TextSpan>[
                                      TextSpan(
                                          text: logic
                                              .getMoney(state.TJlist[index])[1],
                                          style: TextStyle(
                                              decoration:
                                                  TextDecoration.lineThrough,
                                              fontSize: EsSizes.XS,
                                              color: EsColors.ContentSecondary,
                                              fontWeight:
                                                  EsFontWeights.Medium)),
                                    ]),
                              ),
                              if (state.TJlist[index]['fresh_type'] != 8)
                                GestureDetector(
                                  onTap: () {
                                    if (state.TJlist[index]['style_store'] >
                                        0) {
                                      logic.addShoppingCart(
                                          ec_shop_num_id: state.TJlist[index]
                                                  ['shop_num_id']
                                              .toString(),
                                          item_num_id: state.TJlist[index]
                                                  ['default_item_num_id']
                                              .toString(),
                                          style_num_id: state.TJlist[index]
                                                  ['style_num_id']
                                              .toString(),
                                          ec_style_num_id: state.TJlist[index]
                                                  ['ec_style_num_id']
                                              .toString());
                                    }
                                  },
                                  child: Image.asset(
                                    'assets/images/shoppingCart_image.png',
                                    color:
                                        state.TJlist[index]['style_store'] > 0
                                            ? Color(0xffEA5504)
                                            : Color(0xffcccccc),
                                    width: setWidth(50),
                                    height: setWidth(50),
                                    fit: BoxFit.cover,
                                  ),
                                ),
                            ],
                          ),
                        ],
                      ),
                    ),
                  )),
        ),
      );
    }

    final details = Get.arguments as Map;
    return Scaffold(
        resizeToAvoidBottomInset: false,
        appBar: AppBar(
          backgroundColor: Config.mainColor,
          brightness: Brightness.light,
          iconTheme: IconThemeData(color: Colors.white),
          title: Text(
            "订单完成",
            style: TextStyle(color: Colors.white, fontSize: 32.sp),
          ),
          leading: IconButton(
              icon: Icon(Icons.arrow_back),
              onPressed: () {
                Get.offAllNamed(RouteConfig.main);
              }),
          centerTitle: true,
          elevation: 0,
        ),
        body: GetBuilder<orderCompleteLogic>(builder: (logic) {
          return ListView(
            children: [
              Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
                SizedBox(
                  height: 80.w,
                ),
                Center(
                  child: Icon(
                    Icons.check_circle,
                    size: 48,
                    color: Colors.deepOrange,
                  ),
                ),
                SizedBox(
                  height: 20.w,
                ),
                Text(
                  "订单编号:${SpUtil.getString('dingdan') == null ? '' : SpUtil.getString('dingdan')}",
                  style: TextStyle(
                    fontSize: 26.w,
                    color: Colors.grey[600],
                  ),
                ),
                SizedBox(
                  height: 10.w,
                ),
                // Text(
                //   "实付:${details==null?'':details['shifu']}",
                //   style: TextStyle(
                //     fontSize: 26.w,
                //     color: Colors.grey[600],
                //   ),
                // ),
                SizedBox(
                  height: 60.w,
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    GestureDetector(
                      onTap: () {
                        Get.offAllNamed(
                          RouteConfig.main,
                        );
                      },
                      child: Container(
                        decoration: new BoxDecoration(
                            border: new Border.all(
                                color: Colors.deepOrange, width: 0.5),
                            color: Colors.white,
                            borderRadius: new BorderRadius.circular((20.0))),
                        padding: EdgeInsets.only(
                            top: 12.w, bottom: 12.w, left: 24.w, right: 24.w),
                        child: Text(
                          '返回首页',
                          style: TextStyle(color: Colors.deepOrange),
                        ),
                      ),
                    ),
                    SizedBox(
                      width: 30.w,
                    ),
                    GestureDetector(
                      onTap: () {
                        Navigator.pushNamed(context, RouteConfig.order,
                            arguments: {'status': 0});

                        // Get.toNamed(RouteConfig.orderList,
                        //     arguments: {'status': 0});
                      },
                      child: Container(
                        decoration: new BoxDecoration(
                            border: new Border.all(
                                color: Colors.deepOrange, width: 0.5),
                            color: Colors.white,
                            borderRadius: new BorderRadius.circular((20.0))),
                        padding: EdgeInsets.only(
                            top: 12.w, bottom: 12.w, left: 24.w, right: 24.w),
                        child: Text(
                          '查看详情',
                          style: TextStyle(color: Colors.deepOrange),
                        ),
                      ),
                    ),
                  ],
                ),
                // 广告
                state.advertising.length > 0
                    ? Column(
                        children: _newList(state.advertising),
                      )
                    : Text(''),
                SizedBox(
                  height: 60.w,
                ),
                _guessLickTitle(), _guessLick()
              ])
            ],
          );
        }));
  }

  Widget _getDate(start, end) {
    var startTime = start.split(" ")[0];
    var endTime = end.split(" ")[0];
    return Container(
      // width: 300.w,
      margin: EdgeInsets.only(bottom: 10.0),
      child: Text(
        '有效期 $startTime -- $endTime',
        style: TextStyle(
          color: Color(0xff333333),
        ),
      ),
    );
  }

//  优惠券类型
  Widget _couponType(String typeIndex) {
    var type = '折扣券';
    if (typeIndex == '0') {
      type = '折扣券';
    } else if (typeIndex == '1') {
      type = '现金券';
    } else if (typeIndex == '2') {
      type = '免邮券';
    } else if (typeIndex == '8') {
      type = '兑换券';
    }

    return Container(
      child: Text(
        type,
        style: TextStyle(
          color: Color(0xffa5673f),
          fontSize: 16,
          fontWeight: FontWeight.bold,
        ),
      ),
    );
  }

  List<Widget> _newList(dynamic adList) {
    var commonWidgets = List<Widget>();
    for (var item in adList) {
      if (item['adv_type'] == '1') {
        commonWidgets.add(
          Container(
            margin: EdgeInsets.only(bottom: 20.w),
            child: Stack(
              children: <Widget>[
                new Image(
                  width: 750.r,
                  height: 375.r,
                  fit: BoxFit.fill,
                  image: new NetworkImage(
                    item['adv_object_url'],
                  ),
                ),
                item['tag_name'] != null
                    ? Positioned(
                        //方法二
                        right: 20.w,
                        bottom: 20.w,
                        child: new Container(
                          padding: EdgeInsets.only(
                            left: 6.0,
                            right: 6.0,
                            top: 2.0,
                            bottom: 2.0,
                          ),
                          decoration: BoxDecoration(
                            border: Border.all(
                              width: 1,
                              color: Color(0xff708090),
                            ),
                            borderRadius: BorderRadius.all(
                              Radius.circular(10),
                            ),
                          ),
                          child: Text(
                            item['tag_name'],
                            style: TextStyle(
                              color: Color(0xff708090),
                              fontSize: 10,
                            ),
                          ),
                        ),
                      )
                    : Container(),
              ],
            ),
          ),
        );
      } else if (item['adv_type'] == '2') {
        commonWidgets.add(
          Container(
            margin: EdgeInsets.only(bottom: 20.w),
            child: Stack(
              children: <Widget>[
                new VideoPlayerPlus(
                  VideoPlayerController.network(item['adv_object_url']),
                ),
                item['tag_name'] != null
                    ? Positioned(
                        //方法二
                        right: 20.w,
                        bottom: 20.w,
                        child: new Container(
                          padding: EdgeInsets.only(
                            left: 6.0,
                            right: 6.0,
                            top: 2.0,
                            bottom: 2.0,
                          ),
                          decoration: BoxDecoration(
                            // color: Color(0xff708090),
                            border: Border.all(
                              width: 1,
                              color: Color(0xff708090),
                            ),
                            borderRadius: BorderRadius.all(
                              Radius.circular(10),
                            ),
                          ),
                          child: Text(
                            item['tag_name'],
                            style: TextStyle(
                              color: Color(0xff708090),
                              fontSize: 10,
                            ),
                          ),
                        ),
                      )
                    : Container(),
              ],
            ),
          ),
        );
      } else if (item['adv_type'] == '3') {
        Map<String, dynamic> user = jsonDecode(item['style_num_name']);
        user.forEach((key, value) {
          value[0]['shop_num_id'] = key;
          item['mdms_style'] = value[0];
        });
        commonWidgets.add(
          InkWell(
            onTap: () {
              String itemNumId =
                  item['mdms_style']['default_item_num_id'].toString();
              String styleNumId = item['mdms_style']['style_num_id'].toString();
              String ecStyleNumId =
                  item['mdms_style']['ec_style_num_id'].toString();
              Get.toNamed(RouteConfig.goodsDetail, arguments: {
                'itemNumId': itemNumId,
                'styleNumId': styleNumId,
                'shopId': item['mdms_style']['shop_num_id'],
                'ecStyleNumId': ecStyleNumId,
                'typeIndex': item['mdms_style']['is_pre_sale'] ?? 0,
              });
            },
            child: Container(
              margin: EdgeInsets.only(bottom: 20.w),
              padding: EdgeInsets.only(
                  left: 30.w, right: 30.w, top: 25.w, bottom: 15.w),
              decoration: BoxDecoration(
                  boxShadow: [BoxShadow(color: Colors.grey, blurRadius: 5.0.w)],
                  color: Colors.white,
                  borderRadius: new BorderRadius.circular((20.0.w))),
              child: Column(
                children: [
                  Container(
                    constraints: BoxConstraints(minHeight: 250.w),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          // width: 300.w,
                          child: Image.network(
                            item['mdms_style']['image_default_id'],
                            width: 250.w,
                            height: 220.w,
                            fit: BoxFit.cover,
                          ),
                        ),
                        Expanded(
                          child: Container(
                            margin: EdgeInsets.only(left: 30.w),
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Container(
                                  alignment: Alignment.centerLeft,
                                  child: Text(
                                    item['mdms_style']['style_num_name'],
                                    style: TextStyle(
                                      color: Color(0xff666666),
                                      fontWeight: FontWeight.bold,
                                      fontSize: 30.w,
                                    ),
                                  ),
                                ),
                                Stack(
                                  children: [
                                    item['tag_name'] != null
                                        ? Positioned(
                                            //方法二
                                            right: 0,
                                            bottom: 0,
                                            child: new Container(
                                              padding: EdgeInsets.only(
                                                left: 6.0,
                                                right: 6.0,
                                                top: 2.0,
                                                bottom: 2.0,
                                              ),
                                              decoration: BoxDecoration(
                                                // color: Color(0xff708090),
                                                border: Border.all(
                                                  width: 1,
                                                  color: Color(0xff708090),
                                                ),
                                                borderRadius: BorderRadius.all(
                                                  Radius.circular(30),
                                                ),
                                              ),
                                              child: Text(
                                                item['tag_name'],
                                                style: TextStyle(
                                                  color: Color(0xff708090),
                                                  fontSize: 10,
                                                ),
                                              ),
                                            ),
                                          )
                                        : Container(),
                                    Container(
                                      alignment: Alignment.centerLeft,
                                      margin: EdgeInsets.only(top: 80.w),
                                      child: Text(
                                        '¥ ${item['mdms_style']['price']}',
                                        style: TextStyle(
                                          color: Color(0xff666666),
                                          fontWeight: FontWeight.bold,
                                          fontSize: 30.w,
                                        ),
                                      ),
                                    ),
                                  ],
                                )
                              ],
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
        );
      } else if (item['adv_type'] == '4') {
        commonWidgets.add(
          InkWell(
            onTap: () {
              // 拼团
              if (item['results'][0]['ecactivity_classify'] == 1) {
                Map<String, dynamic> map = {
                  'icon_name': item['activity_num_name'],
                  'activity_num_id': item['activity_num_id'],
                  'pic_url': '',
                  'linktype': 9,
                  'linktarget': null,
                  'shop_id': item['results'][0]['ec_shop_num_id']
                };
                Get.toNamed(
                  RouteConfig.collage,
                  arguments: {'model': map},
                );
              } else if (item['results'][0]['ecactivity_classify'] == 2) {
                // 限时秒杀
                Map<String, dynamic> map = {'results': item['results']};
                Get.toNamed(
                  RouteConfig.seckillHome,
                  parameters: {},
                  arguments: {'model': map},
                );
              } else if (item['results'][0]['ecactivity_classify'] == 3) {
                // 预售
                Map<String, dynamic> map = {
                  'icon_name': item['activity_num_name'],
                  'pic_url': '',
                  'linktype': 12,
                  'linktarget': item['results'][0]['ecactivity_id'],
                  'shop_id': item['results'][0]['ec_shop_num_id'],
                };
                Get.toNamed(
                  RouteConfig.preSaleActive,
                  arguments: {'model': map},
                );
              } else {
                Map<String, dynamic> map = {
                  'icon_name': item['activity_num_name'],
                  'activity_num_id': item['activity_num_id'],
                  'pic_url': '',
                  'linktype': 9,
                  'linktarget': null
                };
                Get.toNamed(
                  RouteConfig.collage,
                  arguments: {'model': map},
                );
              }
            },
            child: Container(
              margin: EdgeInsets.only(bottom: 20.w, top: 20.w),
              child: Stack(
                children: <Widget>[
                  item['results'].length != 0
                      ? new Image(
                          image: new NetworkImage(
                            item['activity_cover_url'],
                          ),
                        )
                      : Container(),
                  item['tag_name'] != null && item['results'].length != 0
                      ? Positioned(
                          //方法二
                          right: 20.w,
                          bottom: 20.w,
                          child: new Container(
                            padding: EdgeInsets.only(
                              left: 6.0,
                              right: 6.0,
                              top: 2.0,
                              bottom: 2.0,
                            ),
                            decoration: BoxDecoration(
                              border: Border.all(
                                width: 1,
                                color: Color(0xff708090),
                              ),
                              borderRadius: BorderRadius.all(
                                Radius.circular(30),
                              ),
                            ),
                            child: Text(
                              item['tag_name'],
                              style: TextStyle(
                                color: Color(0xff708090),
                                fontSize: 10,
                              ),
                            ),
                          ),
                        )
                      : Container(),
                ],
              ),
            ),
          ),
        );
      } else if (item['adv_type'] == '5') {
        var data = jsonDecode(item['coupon_num_name']);
        commonWidgets.add(
          Container(
            child: ListView.builder(
              physics: NeverScrollableScrollPhysics(),
              shrinkWrap: true,
              itemExtent: 160.0,
              itemCount: data.length,
              itemBuilder: (ctx, index) {
                return InkWell(
                  onTap: data[index]['cover_url'] == null
                      ? () {}
                      : () {
                          toast('领取中...');
                          var params = {
                            "use_platform": 2,
                            "coupon_num_id":
                                data[index]['series'].toString(), //券编码
                            "usr_num_id": SpUtil.getInt('empeNumId'),
                            "access_token": SpUtil.getString('token'),
                            "relation": "领券中心",
                            "qsource": 301,
                            "relation_indate": "永久有效",
                            "user_num_id": SpUtil.getInt('empeNumId'),
                          };
                          Api.getCoupon(params).listen(
                            (event) {
                              toastDismissOther(event['message']);
                            },
                          );
                        },
                  child: Container(
                    constraints: new BoxConstraints.expand(
                      height: 134.0,
                    ),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(4.0),
                      image: DecorationImage(
                        image: NetworkImage("${data[index]['cover_url']}"),
                        fit: BoxFit.cover,
                      ),
                      color: Color(0xfff2c899),
                    ),
                    margin: EdgeInsets.only(bottom: 20.w, top: 20.w),
                    child: Row(
                      children: data[index]['cover_url'] != null
                          ? []
                          : [
                              Container(
                                width: 100.0,
                                margin: EdgeInsets.only(right: 20.w),
                                padding: EdgeInsets.only(left: 20.w),
                                child: Column(
                                  children: [
                                    Container(
                                      height: 30,
                                    ),
                                    data[index]['coupontype'] == '0'
                                        ? Row(
                                            children: [
                                              Text(
                                                '${data[index]['face_value'] / 10}',
                                                style: TextStyle(
                                                  color: Color(0xffa5673f),
                                                  fontSize: 36.0,
                                                ),
                                              ),
                                              Text(
                                                '折',
                                                style: TextStyle(
                                                  color: Color(0xffa5673f),
                                                ),
                                              ),
                                            ],
                                          )
                                        : Row(
                                            children: [
                                              Text(
                                                '¥',
                                                style: TextStyle(
                                                  color: Color(0xffa5673f),
                                                ),
                                              ),
                                              Text(
                                                '${data[index]['face_value']}',
                                                style: TextStyle(
                                                  color: Color(0xffa5673f),
                                                  fontSize: 36.0,
                                                ),
                                              ),
                                            ],
                                          ),
                                    Container(
                                      margin: EdgeInsets.only(top: 4.0),
                                      child: _couponType(
                                          data[index]['coupontype']),
                                    ),
                                  ],
                                ),
                              ),
                              Expanded(
                                child: Stack(
                                  children: [
                                    item['tag_name'] != null
                                        ? Positioned(
                                            //方法二
                                            right: 20.w,
                                            bottom: 20.w,
                                            child: new Container(
                                              padding: EdgeInsets.only(
                                                left: 6.0,
                                                right: 6.0,
                                                top: 2.0,
                                                bottom: 2.0,
                                              ),
                                              decoration: BoxDecoration(
                                                border: Border.all(
                                                  width: 1,
                                                  color: Color(0xff708090),
                                                ),
                                                borderRadius: BorderRadius.all(
                                                  Radius.circular(10),
                                                ),
                                              ),
                                              child: Text(
                                                item['tag_name'],
                                                style: TextStyle(
                                                  color: Color(0xff708090),
                                                  fontSize: 10,
                                                ),
                                              ),
                                            ),
                                          )
                                        : Container(),
                                    Container(
                                      // width: 400.w,
                                      child: Column(
                                        mainAxisAlignment:
                                            MainAxisAlignment.start,
                                        crossAxisAlignment:
                                            CrossAxisAlignment.start,
                                        children: [
                                          Container(
                                            margin:
                                                EdgeInsets.only(bottom: 10.0),
                                            padding: EdgeInsets.only(top: 18.w),
                                            child: Text(
                                              data[index]['title'],
                                              style: TextStyle(
                                                color: Color(0xff000000),
                                                fontSize: 18.0,
                                              ),
                                            ),
                                          ),
                                          Container(
                                            child: item['start_time'] != null &&
                                                    item['end_time'] != null
                                                ? _getDate(item['start_time'],
                                                    item['end_time'])
                                                : Container(),
                                          ),
                                          InkWell(
                                            onTap: () {
                                              toast('领取中...');
                                              var params = {
                                                "use_platform": 2,
                                                "coupon_num_id": data[index]
                                                        ['series']
                                                    .toString(), //券编码
                                                "usr_num_id":
                                                    SpUtil.getInt('empeNumId'),
                                                "access_token":
                                                    SpUtil.getString('token'),
                                                "relation": "领券中心",
                                                "qsource": 301,
                                                "relation_indate": "永久有效",
                                                "user_num_id":
                                                    SpUtil.getInt('empeNumId'),
                                              };
                                              Api.getCoupon(params).listen(
                                                (event) {
                                                  toastDismissOther(
                                                      event['message']);
                                                },
                                              );
                                            },
                                            child: Container(
                                              padding: EdgeInsets.only(
                                                left: 10.0,
                                                right: 10.0,
                                                top: 4.0,
                                                bottom: 8.0,
                                              ),
                                              margin:
                                                  EdgeInsets.only(bottom: 20.w),
                                              decoration: BoxDecoration(
                                                color: Color(0xffa5673f),
                                                borderRadius:
                                                    BorderRadius.circular(20.0),
                                              ),
                                              child: Text(
                                                '立即领取',
                                                style: TextStyle(
                                                  color: Color(0xffffffff),
                                                  fontSize: 16,
                                                ),
                                              ),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                    ),
                  ),
                );
              },
            ),
          ),
        );
      }
    }
    return commonWidgets;
  }
}

// Get.toNamed(RouteConfig.orderList,arguments: {
//                     'status':0
//                   });
